package com.ruoyi.bigScreen.controller;

import com.ruoyi.bigScreen.domain.vo.BigScreenChannelSetData;
import com.ruoyi.bigScreen.service.IBigScreenChannelSetDataService;
import com.ruoyi.common.core.domain.business.waterDistribution.ChannelSetData;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.web.page.TableDataInfo;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.math.BigDecimal;
import java.util.List;

/**
 * 设定渠道数据Controller
 *
 * @author hwd
 * @date 2023-07-13
 */
@RestController
@RequestMapping("/ChannelSetData")
public class BigScreenChannelSetDataController extends BaseController
{
    @Autowired
    private IBigScreenChannelSetDataService channelSetDataService;

    /**
     * 查询设定渠道数据列表
     */
    @RequiresPermissions("waterDistribution:ChannelSetData:list")
    @GetMapping("/list")
    public AjaxResult list(BigScreenChannelSetData channelSetData)
    {
        List<BigScreenChannelSetData> list = channelSetDataService.selectChannelSetDataList(channelSetData);
        if(list.size()>0){
            for (BigScreenChannelSetData b:list
                 ) {
                if (b.getTotalIrrigationArea()!=null){
                    b.setTotalIrrigationArea(b.getTotalIrrigationArea().divide(new BigDecimal("10000"),2,BigDecimal.ROUND_HALF_UP));
                }
                if (b.getDesignWaterPriceReform()!=null){
                    b.setDesignWaterPriceReform(b.getDesignWaterPriceReform().divide(new BigDecimal("10000"),2,BigDecimal.ROUND_HALF_UP));
                }

            }
        }
        return AjaxResult.success(list.get(0));
    }


}
